<template>
	<view>
		<view class="main">
			<view class="info" @click="showDetail">
				<view class="price">
					<text class="symbol">hk$</text>
					11086.00
				</view>
				<view class="bag">
					{{$t('buy-car')}} <text class="num">66</text>
				</view>
			</view>
			<view class="settle" @click="settle">{{$t('buy-car.settle')}}</view>
		</view>
		<u-popup :show="showPopup" round="24rpx" :close-on-click-overlay="true">
			<view class="popup" :style="{height: ($u.sys().windowHeight * 0.6) + 'px'}">
				<view class="title">
					<view @click="showPopup = false">{{$t('c.close')}}</view>
					<view class="clear">
						<u-icon name="trash" color="#9EA6B2"></u-icon>
						{{$t('buy-car.clear')}}
					</view>
				</view>
				<view class="list">
					<view v-for="(item, index) in goodsList" :key="index" class="item _card">
						<u-image :src="item.pic" radius="16rpx" show-loading width="168rpx" height="168rpx"></u-image>
						<view class="info">
							<view class="name u-line-1">{{item.name}}</view>
							<view class="parameter">
								{{$t('goods.sales')}}: {{item.sales}}
								<text style="margin-left: 24rpx;">{{$t('goods.energy')}}: {{item.energy}}</text>
							</view>
							<view class="tags">
								<view v-for="(tag, index) in item.tags" :key="index" class="tag">{{tag}}</view>
							</view>
							<view class="price-box">
								<view class="price">
									<text class="symbol">$</text>{{item.price}}
								</view>
								<num-box type="" />
							</view>
						</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import numBox from './num-box.vue'
	export default {
		components: {
			numBox
		},
		data() {
			return {
				showPopup: false,
				goodsList: [{
						id: 1,
						pic: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
						name: '這是早餐',
						sales: 88,
						energy: 108,
						tags: ['好吃', '配送快'],
						price: 10.86
					},
					{
						id: 2,
						pic: 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
						name: '這是午餐',
						sales: 88,
						energy: 108,
						tags: ['肥牛不错'],
						price: 10.86
					}
				]
			}
		},
		onShow() {

		},
		methods: {
			calc() {

			},
			showDetail() {
				this.showPopup = !this.showPopup
			},
			settle() {
				uni.navigateTo({
					url: '/pages/order/settle'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.main {
		z-index: 10076;
		position: fixed;
		bottom: 12rpx;
		width: calc(100% - 48rpx);
		margin: 0 24rpx;
		border-radius: 52rpx;
		height: 104rpx;
		display: flex;
		overflow: hidden;
		justify-content: space-between;
		background-color: #033787;

		.info {
			padding: 8rpx 52rpx;
			color: #fff;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.price {
				font-size: 36rpx;
				font-weight: 600;

				.symbol {
					margin-right: 4rpx;
					font-size: 16rpx;
				}
			}

			.bag {
				font-size: 22rpx;
				display: flex;

				.num {
					margin-left: 16rpx;
					background-color: #E35525;
					border: 1rpx solid #fff;
					padding: 0 4rpx;
					border-radius: 16rpx;
				}
			}
		}

		.settle {
			width: 248rpx;
			background-color: #E35525;
			color: #fff;
			font-size: 36rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}

	.popup {
		padding: 16rpx 16rpx 110rpx 16rpx;
		overflow-y: auto;
	}
	
	.title {
		height: 48rpx;
		margin-bottom: 24rpx;
		display: flex;
		justify-content: space-between;
		font-size: 28rpx;
		color: #9EA6B2;
		
		.clear {
			display: flex;
		}
	}

	.list {
		padding-bottom: 24rpx;

		.item {
			display: flex;
			height: 168rpx;
			padding: 0;
			margin: 0;
			margin-bottom: 24rpx;

			.info {
				width: calc(100% - 108rpx);
				margin-left: 24rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.name {
					font-size: 30rpx;
					color: #0C1626;
					font-weight: 600;
				}

				.parameter {
					font-size: 22rpx;
					color: #B9BFCB;
				}

				.tags {
					display: flex;

					.tag {
						font-size: 18rpx;
						border-radius: 4rpx;
						padding: 2rpx 6rpx;
						color: #fff;
						margin-right: 8rpx;
						background-color: #E35525;
					}
				}

				.price-box {
					display: flex;
					justify-content: space-between;
					align-items: flex-end;

					.price {
						color: #E35525;
						font-size: 30rpx;

						.symbol {
							font-size: 16rpx;
						}
					}
				}
			}
		}
	}
</style>